package demo1;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-07-14
 * Time: 20:06
 */
public class Test01 {
    private String name = "haha";
    private String password = "123";
    public void isName(String name)throws IsNameException {
        if(!this.name.equals(name)) {
            throw new IsNameException("输入名字错误!");
        }
    }
    public void isPassword(String password)throws IsPasswordException {
        if(!this.password.equals(password)) {
            throw new IsPasswordException("输入密码错误!");
        }
    }
    public static void main(String[] args) throws IsNameException,IsPasswordException{
        Scanner sc = new Scanner(System.in);
        Test01 test = new Test01();
        try {
            System.out.println("请输入你的账号：");
            String s1 = sc.nextLine();
            test.isName(s1);
            System.out.println("请输入你的密码：");
            String s2 = sc.nextLine();
            test.isPassword(s2);
        }catch(IsNameException e) {
            e.printStackTrace();
            System.out.println("捕获了IsNameException异常");
        }catch(IsPasswordException e ) {
            e.printStackTrace();
            System.out.println("捕获了IsPasswordException异常");
        }
    }
}
